package com.xiaozhu.common.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 朱慧军
 * @version 1.0
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private int code;
    private String msg;
    private T data;

    // 构造、getter、setter等省略


    public static <T> Result<T> success(T data) {
        return new Result<T>(200, "成功", data);
    }

    public static<T> Result<T> success(String msg) {
        return new Result<T>(200, msg, null);
    }

    public static<T> Result<T> success() {
        return new Result<T>(200, null, null);
    }





    public static<T> Result<T> fail(String msg) {
        return new Result<T>(500, msg, null);
    }

    public static<T> Result<T> failAdmin() {
        Result<T> result = new Result<T>();
        result.setCode(500);
        result.setData(null);
        result.setMsg("没有权限~如果需要操作请联系管理员");
        return result;
    }

}
